import request from '@/utils/request'
//注册接口
export const userRegisterService = async (data: any) => {
  const res = await request.post('/api/reg', data)
  return res
}

export const userLoginService = async (data: any) => {
  const res = await request.post('/api/login', data)
  return res
}

//token  在请求头 请求拦截器已携带
export const getUserInfoService = async () => {
  const res = await request.get('/my/userinfo')
  return res
}

//修改用户信息
export const updateUserInfoService = async ({ id, nickname, email }: any) => {
  const res = await request.put('/my/userinfo', { id, nickname, email })
  return res
}

//修改头像
export const updateAvatarService = async (avatar: string) => {
  const res = await request.patch('/my/update/avatar', { avatar })
  return res
}

//修改密码
export const updatePwdService = async (data: any) => {
  const res = await request.patch('/my/updatepwd', data)
  return res
}
